#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'wshu'
__version__ = '1.0'
"""
    ***********************************
    *  @filename : write_redis.py
    *  @Author : wshu
    *  @CodeDate : 2020/3/27 11:18
    *  @Software : PyCharm
    ***********************************
"""
import redis

pool = redis.ConnectionPool(host='10.101.1.235', password='cecgw@12345', port=6379, db=8, decode_responses=True) # decode_responses: 写入的键值对中的value为str类型，不加这个参数写入的则为字节类型
redis_cli = redis.Redis(connection_pool=pool)
redis_key = 'hf:start_urls'

# options write data
domain = ['https://www.cec.com.cn/', 'http://www.fujian.gov.cn/',
          'https://www.henan.gov.cn/', 'http://www.cecgw.com.cn/']

# fulshdb = redis_cli.flushdb()


with open('fujian_scan.txt', 'r', encoding='utf-8') as fp:
    links = [item.strip() for item in fp.readlines()]
    for link in links:
        redis_cli.lpush(redis_key, link)